package br.usp.poli.dao;

import java.util.List;

import org.hibernate.Session;

import br.usp.poli.entity.DataSetMetadata;
import br.usp.poli.entity.Experiment;

public class ExperimentDao {
	private GenericDao<Experiment, Long> dao;
	private GenericDao<DataSetMetadata, Long> metadataDao;

	public ExperimentDao(Session session) {
		super();
		this.metadataDao = GenericDao.getInstance(session, DataSetMetadata.class);
		this.dao = GenericDao.getInstance(session, Experiment.class);
	}

	public void delete(Experiment t) {
		dao.delete(t);
	}

	public List<Experiment> list() {
		return dao.list();
	}

	public Experiment load(Long id) {
		return dao.load(id);
	}

	public void merge(Experiment t) {
		dao.merge(t);
	}

	public void save(Experiment t) {
		metadataDao.save(t.getDataSetMetadata());
		dao.save(t);
	}

	public void saveOrUpdate(Experiment t)  {
		metadataDao.saveOrUpdate(t.getDataSetMetadata());
		dao.saveOrUpdate(t);
	}

}
